#include "widget.h"
#include "ui_widget.h"
#include <thread>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //设置定时任务，让10减到0
    timer = new QTimer(this);
    connect(timer,&QTimer::timeout,this,&Widget::handle);

    timer->start(1000);

    std::this_thread::sleep_for(std::chrono::seconds(10));
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handle()
{

    int tim = ui->lcdNumber->intValue();
    if(tim <= 0)
    {
        timer->stop();
        return;
    }
    ui->lcdNumber->display(tim - 1);
}

